﻿using System.Threading.Tasks;
using MassTransit;
using Shared.Service.EventBus.Events;

namespace Shared.Service.EventBus
{
    public class DistributedEventBus : IDistributedBus
    {
        private readonly IPublishEndpoint _endpoint;

        public DistributedEventBus(IPublishEndpoint endpoint)
        {
            _endpoint = endpoint;
        }

        public async Task PublishAsync<T>(T @event) where T : class
        {
            await _endpoint.Publish<ExternalEvent>(@event);
            //var endpoint = await _sendEndpointProvider.GetSendEndpoint(_setting.EndpointUri);
            //await endpoint.Send(@event);
        }
    }
}
